<?php 
 
namespace App\Http\Controllers\Admin; 
 
use Illuminate\Http\Request; 
use App\Http\Controllers\Controller; 
use Illuminate\Foundation\Auth\ThrottlesLogins; 
use Illuminate\Foundation\Auth\AuthenticatesUsers; 
use  Config;

class LoginController extends Controller 
{ 
    use AuthenticatesUsers; 
 
    /** 
     * Where to redirect users after login / registration. 
     * 
     * @var string 
     */ 
    protected $redirectTo = '/admin/index'; 
    protected $username; 
 
    /** 
     * Create a new controller instance. 
     * 
     * @return void 
     */ 
    public function __construct() 
    {   
        Config::set('cache.default','array');
        $this->middleware('guest:admin', ['except' => 'logout']); 
        //$this->username = config('admin.global.username');
        //print_r($this->$username);exit; 
    } 
 
    /** 
     * 重写登录视图页面 
     */ 
    public function showLogin() 
    { 
        return view('admin.login.login'); 
    } 
    
    /** 
     * 自定义认证驱动 
     * @return mixed 
     */ 
    protected function guard() 
    {   
        return auth()->guard('admin'); 
    } 
    
    public function logout(Request $request)
    {
        // dd('123');
        $this->guard('admin')->logout();

        $request->session()->invalidate();

        return redirect('/admin/login');
    }
} 